<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
<style>
    .box1{
        /* 给元素添加相对定位 */
        position: relative;
        /* top优先于bottom: ;l>r */
        top: 100px;
        left: 100px;
        width: 200px;
        height: 200px;
        background-color: pink;
    }
    .box2{
        
        width: 200px;
        height: 200px;
        background-color: aqua;
    }
    .son1{
        /* 绝对定位,不占空间 ，相对于祖先元素定位或 视口*/
        position: absolute;
        top: 150px;
        left: 150px;
        width: 150px;
        height: 150px;
        background-color: black;
    }
    .son1{
        width: 120px;
        height: 120px;
        background-color:blueviolet
    }
</style>
</head>
<body>
    <!-- 子绝父相 子绝对定位 父加相对定位（占位置且定位）-->
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="father">
        <div class="son1"></div>
        <div class="son2"></div>
    </div>
</body>
</html>